using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class HealthWindowClass : MonoBehaviour{
	
	public UILabel MaxHPLabel;
	public UILabel TotalDamageLabel;
	public UILabel DamageHealingInputLabel;
	public UILabel StatusLabel;
	public UILabel TotalHPLabel;
	public UILabel ClassHPLabel;
	public UILabel ConBonusLabel;
	public UIInput MiscInputLabel;
	public UILabel TotalHPLabel2;
	
	public UILabel NonLethalTotal;
	public GameObject minusNLDButton;
	public GameObject plusNLDButton;
	
	public CharacterSheet character;
	
	void Start()
	{	
	}
	
	void Update()
	{
	}
	
	public void LoadCharacter(CharacterSheet character)
	{
		this.character = character;
		UpdateTextLabels();
	}
	
	void UpdateTextLabels()
	{
		MaxHPLabel.text = character.HP.ToString();
		TotalDamageLabel.text = character.Damage.ToString();
		StatusLabel.text = character.hpStatus;
		TotalHPLabel.text = (character.HP - character.Damage).ToString();
		ClassHPLabel.text = character.classHP.ToString();
		ConBonusLabel.text = character.conHP.ToString();
		MiscInputLabel.text = character.bonusHP.ToString();
		TotalHPLabel2.text = TotalHPLabel.text;
		NonLethalTotal.text = character.nonLethalDamage.ToString();
	}
	
	void HealDamage()
	{
		character.Heal(DamageHealingInputLabel.text);
		DamageHealingInputLabel.text = "1";
		UpdateTextLabels();
	}
	
	void TakeDamage()
	{
		character.TakeDamage(DamageHealingInputLabel.text);
		DamageHealingInputLabel.text = "1";
		UpdateTextLabels();
	}
	
	void HealNLD()
	{
		if(character.nonLethalDamage > 0)
			character.nonLethalDamage--;
		UpdateTextLabels();
	}
	
	void TakeNLD()
	{
		if(character.nonLethalDamage < character.HP)
			character.nonLethalDamage++;
		UpdateTextLabels();
	}
	
	void OnSubmitMiscHPUpdate()
	{
		Debug.Log("Updating Bonus HP");
		character.SetBonusHP(MiscInputLabel.text);
		UpdateTextLabels();
	}
	
	void RandomizeClassHP()
	{
		character.RandomizeHP();
		UpdateTextLabels();
	}
	
	void Commit()
	{
		Destroy(gameObject);
	}
	
}
